
import numpy

from util import dot, unit, norm

class AQuickMin:

    def __init__(self, speck, potential, dt = 0.2, maxStep = 0.2):
        self.speck = speck
        self.potential = potential
        self.dt = dt
        self.maxStep = maxStep
        self.v = self.speck.r * 0.0
        
    def step(self):
        self.potential.force(self.speck)
        dV = self.speck.f * self.dt
        if dot(self.speck.f, self.v) < 0:
            self.v = dV
            self.dt *= 0.9
        else:
            self.v += dV
            self.dt *= 1.01
        dR = self.v * self.dt
        if norm(dR) > self.maxStep:
            dR = unit(dR) * self.maxStep    
        self.speck.r += dR
        
        
        
                
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
